package leetcode.code1306;

public class Solution1 {

	boolean[] been;
	boolean ans;
	int len;

	public boolean canReach(int[] arr, int start) {
		len = arr.length;
		been = new boolean[len];
		ans = false;
		this.f(arr, start);
		return ans;
	}

	private void f(int[] arr, int start) {
		if (ans || start < 0 || start >= len || been[start]) {
			return;
		}
		been[start] = true;
		if (arr[start] == 0) {
			ans = true;
			return;
		}
		this.f(arr, start - arr[start]);
		this.f(arr, start + arr[start]);
	}

}
